import axios from "axios"

//注册接口
export const reqregister = (user) =>{
    return axios({
        url: "/api/register",
        method: "post",
        data: user,
    })
}

//登陆接口
export const reqlogin = (user) =>{
    return axios({
        url: "/api/login",
        method: "post",
        data:user
    })
}
//首页分类
export const reqhomecat = () =>{
    return axios({
        url: "/api/getcate",
        method: "get",
    })
}
//首页轮播
export const reqhomebanner = () =>{
    return axios({
        url: "/api/getbanner",
        method: "get",
    })
}
//首页商品
export const reqhomegoods=()=>{
    return axios({
        url:"/api/gethortgoods",
        method:"get"
    })
}
//商品列表
export const reqlist = (user) => {
    return axios({
        url: "/api/getgoodlist",
        method: "get",
        params: user,
    })
}
// 商品详情
export const reqdetail = (user) => {
    return axios({
        url: "/api/getgoodsinfo",
        method: "get",
        params: user
    })
}
//购物车添加
export const reqcartadd = (user) => {
    return axios({
        url: "/api/cartadd",
        method: "post",
        data: user,
        headers: {
            authorization: JSON.parse(localStorage.getItem("isLogin")).token
        }
    })
}

//购物车列表
export const reqcartlist = (user) => {
    return axios({
        url: "/api/cartlist",
        method: "get",
        params:user,
        headers: {
            authorization: JSON.parse(localStorage.getItem("isLogin")).token
        }
    })
}

//购物车修改
export const reqcartedit=(user)=>{
    return axios({
        url:"/api/cartedit",
        method:"post",
        data:user,
        headers: {
            authorization: JSON.parse(localStorage.getItem("isLogin")).token
        }
    })
}